package com.ymatou.iapi.optrade.parameter.vo;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.ymatou.iapi.optrade.parameter.utill.Utils;

public class OrderItemVoForTax {

	private int productNum;
	
	private BigDecimal productPrice;
	
	private BigDecimal freight;
	
	private BigDecimal prodTaxRate;
	
	private String catalogId;
	
	private String productId;
	
	private Boolean fullReductionFreeFreight;
	
	/**
	 * 以下参数做验证用，非传入参数
	 */
	
	// 分摊的商家折扣金额
	private BigDecimal discount = BigDecimal.ZERO;
	
	// 分摊的买手促销金额
	private BigDecimal sellerPromotionValue;
	
	// 分摊的商家优惠券金额
	private BigDecimal sellerCouponValue;
	
	// 分配到该商品项的规格优惠
	private List<CatalogApportionVo> catalogApportionVos = new ArrayList<CatalogApportionVo>();
	
	// 享受的商家优惠
	private SellerPromotionVo sellerPromotion;
	
	/**
	 * 订单项剩余最大可优惠金额
	 *
	 * @return
	 */
	public BigDecimal calcMaxPromotionLeft() {
		BigDecimal result = getProductPrice()
				.multiply(new BigDecimal(getProductNum()))
				.subtract(new BigDecimal("0.01"))
				.subtract(Utils.zeroIfNull(sellerCouponValue))
				.subtract(Utils.zeroIfNull(sellerPromotionValue));
		if (result.compareTo(BigDecimal.ZERO) < 0) {
			return BigDecimal.ZERO;
		}
		return result;

	}
	
	public Boolean getFullReductionFreeFreight() {
		return fullReductionFreeFreight;
	}

	public void setFullReductionFreeFreight(Boolean fullReductionFreeFreight) {
		this.fullReductionFreeFreight = fullReductionFreeFreight;
	}

	public int countPromotionProductNum() {
		int count = 0;
		for (CatalogApportionVo v : catalogApportionVos) {
			count += v.getCount();
		}
		return count;
	}

	public int getProductNum() {
		return productNum;
	}

	public void setProductNum(int productNum) {
		this.productNum = productNum;
	}

	public BigDecimal getProductPrice() {
		return productPrice;
	}

	public void setProductPrice(BigDecimal productPrice) {
		this.productPrice = productPrice;
	}

	public BigDecimal getFreight() {
		return freight;
	}

	public void setFreight(BigDecimal freight) {
		this.freight = freight;
	}

	public BigDecimal getProdTaxRate() {
		return prodTaxRate;
	}

	public void setProdTaxRate(BigDecimal prodTaxRate) {
		this.prodTaxRate = prodTaxRate;
	}

	public String getCatalogId() {
		return catalogId;
	}

	public void setCatalogId(String catalogId) {
		this.catalogId = catalogId;
	}

	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	public BigDecimal getDiscount() {
		return discount;
	}

	public void setDiscount(BigDecimal discount) {
		this.discount = discount;
	}

	public BigDecimal getSellerPromotionValue() {
		return sellerPromotionValue;
	}

	public void setSellerPromotionValue(BigDecimal sellerPromotionValue) {
		this.sellerPromotionValue = sellerPromotionValue;
	}

	public BigDecimal getSellerCouponValue() {
		return sellerCouponValue;
	}

	public void setSellerCouponValue(BigDecimal sellerCouponValue) {
		this.sellerCouponValue = sellerCouponValue;
	}

	public List<CatalogApportionVo> getCatalogApportionVos() {
		return catalogApportionVos;
	}

	public void setCatalogApportionVos(List<CatalogApportionVo> catalogApportionVos) {
		this.catalogApportionVos = catalogApportionVos;
	}

	public SellerPromotionVo getSellerPromotion() {
		return sellerPromotion;
	}

	public void setSellerPromotion(SellerPromotionVo sellerPromotion) {
		this.sellerPromotion = sellerPromotion;
	}
}
